﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Text;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    public class AB05AV95Data : BaseFunction
    {
        public int ThreadCount;
        public ArrayList listWVOrder=new ArrayList();
        public AB05AV95Data()
            : base()
        {

        }
        public AB05AV95Data(OracleConnection _OracleDB, IntexReptServBLClient _proxy)
            : base(_OracleDB, _proxy)
        {

        }
        public AB05AV95Data(Dictionary<string, object> DicGlobalPara)
            : base(DicGlobalPara)
        {
        }
        public DataSet GetABPOS(DataRow dwABPOS)
        {
            DataSet set4Return = new DataSet();
            DataSet setLocal = new DataSet();
            DataTable tableLocal = null;

            string ABPAUFKRS = "", ABPAUFLFD = "", ABPAUFPOS = "", ABPART = "",ABPLIEFNR = "";
            if (dwABPOS != null)
            {
                ABPAUFKRS = dwABPOS["ABPAUFKRS"].ToString().Trim();
                ABPAUFLFD = dwABPOS["ABPAUFLFD"].ToString().Trim();
                ABPAUFPOS = dwABPOS["ABPAUFPOS"].ToString().Trim();
                ABPART = dwABPOS["ABPART"].ToString().Trim();
                ABPLIEFNR = dwABPOS["LSNAME1"].ToString().Trim();
            }
            try
            {
                #region reference sql
                /*
                SELECT P.ABPAUFKRS, P.ABPAUFLFD,P.ABPAUFPOS,
P.ABPART,P.ABPVAR,P.ABPFARBE,P.ABPBESCHICH,P.ABPRESMGE,P.ABPSOLLMENGE1,P.ABPRESSTK,P.ABPZUGSTK,P.ABPLIEFDAT, B.WBBDPART AS SIZEBATCHNO,MIN(W.WBEWWERTDAT) AS GISSUEDATE, 0+SUM(W.WBEWMTR) AS GMETER,COUNT(*) AS GPCNUM
FROM ABPOS P LEFT JOIN WBBEW W ON
W.WBEWMANDANT = P.ABPMANDANT AND
W.WBEWAUFKRS=P.ABPAUFKRS AND W.WBEWAUFLFD=P.ABPAUFLFD AND W.WBEWAUFPOS=P.ABPAUFPOS
  LEFT JOIN WBBST B ON W.WBEWMANDANT = B.WBBMANDANT AND W.WBEWRWKRS = B.WBBRWKRS  AND W.WBEWRWLFD = B.WBBRWLFD AND W.WBEWPOS = B.WBBPOS AND W.WBEWMANDANT='00' AND W.WBEWWAKZ='R' AND W.WBEWBS='21' AND W.WBEWAFOLGE='010' AND W.WBEWFC='AV10'
WHERE P.ABPMANDANT='00'  AND P.ABPERLKZ=' '
--AND P.ABPAUFKRS LIKE '%%' AND P.ABPAUFLFD LIKE '%%' AND P.ABPAUFPOS LIKE '%%'  AND P.ABPART LIKE '%%'
AND W.WBEWWERTDAT>='20000328' AND W.WBEWWERTDAT<='20070613'
AND (P.ABPAUFART= 'VA' OR P.ABPAUFART='VF' OR P.ABPAUFART='AM')
 GROUP BY P.ABPAUFKRS, P.ABPAUFLFD,P.ABPAUFPOS,P.ABPART,P.ABPVAR,P.ABPFARBE,P.ABPBESCHICH,P.ABPRESMGE,P.ABPSOLLMENGE1,P.ABPRESSTK,P.ABPZUGSTK,P.ABPLIEFDAT, W.WBEWAUFKRS,W.WBEWAUFLFD,W.WBEWAUFPOS,B.WBBDPART
                 */
                #endregion
                OracleCommand or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT P.ABPAUFKRS, P.ABPAUFLFD,P.ABPAUFPOS,trim(P.ABPART)||'-'||trim(P.ABPFARBE)||'-'||P.ABPVAR AS ARTICLE,"
                    + "P.ABPART,P.ABPVAR,P.ABPFARBE,P.ABPBESCHICH,P.ABPRESMGE,P.ABPSOLLMENGE1,P.ABPRESSTK,P.ABPZUGSTK,P.ABPLIEFDAT,P.ABPERLKZ,P.ABPERLDAT"
                + ", B.WBBDPART AS SIZEBATCHNO,CAST(MIN(W.WBEWWERTDAT) AS VARCHAR(10)) AS GISSUEDATE, "
                + " CAST(0+SUM(W.WBEWMTR) AS VARCHAR(20)) AS GMETER,CAST(COUNT(*) AS VARCHAR(20)) AS GPCNUM"
                + ", '0' AS FMETER,'' AS WEFTYARNSTATUS "
                + " FROM ABPOS P LEFT JOIN WBBEW W ON W.WBEWMANDANT = P.ABPMANDANT "
                + " AND W.WBEWAUFKRS=P.ABPAUFKRS AND W.WBEWAUFLFD=P.ABPAUFLFD AND W.WBEWAUFPOS=P.ABPAUFPOS "
                + " AND  W.WBEWWAKZ='R' AND W.WBEWBS='21' AND W.WBEWAFOLGE='010' AND W.WBEWFC='AV10' "
                + "  LEFT JOIN WBBST B ON W.WBEWMANDANT = B.WBBMANDANT AND W.WBEWRWKRS = B.WBBRWKRS  AND W.WBEWRWLFD = B.WBBRWLFD AND W.WBEWPOS = B.WBBPOS "
                + "  WHERE P.ABPMANDANT='00'  AND P.ABPERLKZ=:ABPERLKZ "
                + " AND W.WBEWBUCHDAT>=:GISSUEDATE AND W.WBEWBUCHDAT<=:FGETDATE "
                + " AND P.ABPLIEFNR LIKE '%" + ABPLIEFNR + "%' "
                + " AND P.ABPART LIKE '%" + ABPART + "%' AND (P.ABPAUFART= 'VA' OR P.ABPAUFART='VF' OR P.ABPAUFART='AM') "
                + " GROUP BY P.ABPAUFKRS, P.ABPAUFLFD,P.ABPAUFPOS,P.ABPART,P.ABPVAR,P.ABPFARBE,P.ABPBESCHICH,P.ABPRESMGE,P.ABPSOLLMENGE1,P.ABPRESSTK,P.ABPZUGSTK,P.ABPLIEFDAT,P.ABPERLKZ,P.ABPERLDAT, B.WBBDPART";
                or1.Parameters.Add("ABPERLKZ", OracleType.NVarChar).Value = dwABPOS["ABPERLKZ"].ToString();
                or1.Parameters.Add("GISSUEDATE", OracleType.NVarChar).Value = dwABPOS["GISSUEDATE"].ToString();
                or1.Parameters.Add("FGETDATE", OracleType.NVarChar).Value = dwABPOS["FGETDATE"].ToString();
                setLocal = Connect2Proxy(or1);

                if (setLocal.Tables.Count > 0)
                {
                    tableLocal = setLocal.Tables[0];
                    tableLocal.TableName = "ABPOS";
                    Queue Q100 = new Queue();
                    Q100.Enqueue("ABPSOLLMENGE1");
                    Q100.Enqueue("ABPRESMGE");
                    DivideBy100(tableLocal, Q100);
                    Queue Q1000 = new Queue();
                    Q1000.Enqueue("GMETER");
                    DivideBy1000(tableLocal, Q1000);

                    byte[] b;
                    string value;
                    string GISSUEDATE = "", sGISSUEDATE;
                    decimal GMETER = 0, sGMETER;
                    decimal GPCNUM = 0, sGPCNUM;
                    string sTemp = "";
                    string SIZEBATCHNO = "";
                    foreach (DataRow dwTemp in tableLocal.Rows)
                    {
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp["ABPFARBE"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp["ABPFARBE"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp["ABPBESCHICH"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp["ABPBESCHICH"] = value;
                        if (dwTemp["GMETER"].ToString().Trim() == "")
                        {
                            dwTemp["GMETER"] = 0;
                        }
                        /*
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp["SIZEBATCHNO"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp["SIZEBATCHNO"] = value;
                      
                        sTemp = dwTemp["SIZEBATCHNO"].ToString().Trim();
                        sGISSUEDATE = dwTemp["GISSUEDATE"].ToString().Trim();
                        sGMETER = System.Convert.ToDecimal(dwTemp["GMETER"].ToString().Trim());
                        sGPCNUM = System.Convert.ToDecimal(dwTemp["GPCNUM"].ToString().Trim());
                        if (!SIZEBATCHNO.Contains(sTemp))
                        {
                            SIZEBATCHNO += sTemp + ";";
                            GISSUEDATE = sGISSUEDATE;
                            GMETER += sGMETER;
                            GPCNUM += sGPCNUM;
                        }
                        SIZEBATCHNO += "***";
                        SIZEBATCHNO = SIZEBATCHNO.Replace(";***", "");
                        SIZEBATCHNO = SIZEBATCHNO.Replace("***", "");
                        SIZEBATCHNO = SIZEBATCHNO.Replace(";", Environment.NewLine);
                        dwTemp["GISSUEDATE"] = GISSUEDATE;
                        dwTemp["GMETER"] = GMETER;
                        dwTemp["GPCNUM"] = GPCNUM;
                        dwTemp["SIZEBATCHNO"] = SIZEBATCHNO;
                        */
                    }
                    set4Return.Merge(setLocal);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex); ;
            }
            return set4Return;
        }
        public DataSet GetABPOSBYABPLFD(DataRow dwABPOS)
        {
            DataSet set4Return = new DataSet();
            DataSet setLocal = new DataSet();
            DataTable tableLocal = null;

            string ABPAUFKRS = "", ABPAUFLFD = "", ABPAUFPOS = "", ABPART = "",ABPLIEFNR = "";
            if (dwABPOS != null)
            {
                ABPAUFKRS = dwABPOS["ABPAUFKRS"].ToString().Trim();
                ABPAUFLFD = dwABPOS["ABPAUFLFD"].ToString().Trim();
                ABPAUFPOS = dwABPOS["ABPAUFPOS"].ToString().Trim();
                ABPART = dwABPOS["ABPART"].ToString().Trim();
                ABPLIEFNR = dwABPOS["LSNAME1"].ToString().Trim();
            }
            try
            {
                OracleCommand or1 = OracleDB.CreateCommand();
                or1.CommandType = CommandType.StoredProcedure;
                or1.CommandText = "hl_getab05av95";
                Connect2Proxy(or1);
                or1.CommandText = "SELECT * FROM ICC_AB05AV95";
                or1.CommandType = CommandType.Text;
                /*
                or1.CommandText = "SELECT P.ABPAUFKRS, P.ABPAUFLFD,P.ABPAUFPOS,P.ABPEALFM,ABPWVDAT,trim(P.ABPART)||'-'||trim(P.ABPFARBE)||'-'||P.ABPVAR AS ARTICLE,"
                     + "P.ABPART,P.ABPVAR,P.ABPFARBE,P.ABPBESCHICH,P.ABPRESMGE,P.ABPSOLLMENGE1,P.ABPRESSTK,P.ABPZUGSTK,P.ABPLIEFDAT,P.ABPERLKZ,P.ABPERLDAT"
                 + ", B.WBBDPART AS SIZEBATCHNO,CAST(MIN(W.WBEWWERTDAT) AS VARCHAR(10)) AS GISSUEDATE, "
                 + " CAST(0+SUM(W.WBEWMTR) AS VARCHAR(20)) AS GMETER,CAST(COUNT(*) AS VARCHAR(20)) AS GPCNUM"
                 + ", '0' AS FMETER "
                 + " FROM ABPOS P LEFT JOIN WBBEW W ON W.WBEWMANDANT = P.ABPMANDANT "
                 + " AND W.WBEWAUFKRS=P.ABPAUFKRS AND W.WBEWAUFLFD=P.ABPAUFLFD AND W.WBEWAUFPOS=P.ABPAUFPOS "
                 + " AND  W.WBEWWAKZ='R' AND W.WBEWBS='21' AND W.WBEWAFOLGE='010' AND W.WBEWFC='AV10' "
                 + "  LEFT JOIN WBBST B ON W.WBEWMANDANT = B.WBBMANDANT AND W.WBEWRWKRS = B.WBBRWKRS  AND W.WBEWRWLFD = B.WBBRWLFD AND W.WBEWPOS = B.WBBPOS "
                 + "  WHERE P.ABPMANDANT='00' AND P.ABPERLKZ=:ABPERLKZ  "
                 + " AND W.WBEWBUCHDAT>=:GISSUEDATE AND W.WBEWBUCHDAT<=:FGETDATE "
                 + " AND  P.ABPAUFKRS=:ABPAUFKRS AND P.ABPAUFLFD=:ABPAUFLFD AND P.ABPAUFPOS=:ABPAUFPOS"
                 + " AND P.ABPLIEFNR LIKE '%" + ABPLIEFNR + "%' "
                 + " AND P.ABPART LIKE '%" + ABPART + "%' AND (P.ABPAUFART= 'VA' OR P.ABPAUFART='VF' OR P.ABPAUFART='AM') "
                 + " GROUP BY P.ABPAUFKRS, P.ABPAUFLFD,P.ABPAUFPOS,P.ABPART,P.ABPVAR,P.ABPFARBE,P.ABPBESCHICH,P.ABPRESMGE,P.ABPSOLLMENGE1,P.ABPRESSTK,P.ABPZUGSTK,P.ABPLIEFDAT, W.WBEWAUFKRS,W.WBEWAUFLFD,W.WBEWAUFPOS,B.WBBDPART"
                 + ",P.ABPERLKZ,P.ABPERLDAT,P.ABPEALFM,P.ABPWVDAT"
                 ;
                or1.Parameters.Add("ABPERLKZ", OracleType.NVarChar).Value = dwABPOS["ABPERLKZ"].ToString();
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                or1.Parameters.Add("GISSUEDATE", OracleType.NVarChar).Value = dwABPOS["GISSUEDATE"].ToString();
                or1.Parameters.Add("FGETDATE", OracleType.NVarChar).Value = dwABPOS["FGETDATE"].ToString();
                */
                setLocal = Connect2Proxy(or1);

                if (setLocal.Tables.Count > 0)
                {
                    tableLocal = setLocal.Tables[0];
                    tableLocal.TableName = "ABPOS";
                    Queue Q100 = new Queue();
                    Q100.Enqueue("ABPSOLLMENGE1");
                    Q100.Enqueue("ABPRESMGE");
                    DivideBy100(tableLocal, Q100);
                    Queue Q1000 = new Queue();
                    Q1000.Enqueue("GMETER");
                    DivideBy1000(tableLocal, Q1000);

                    byte[] b;
                    string value;
                    foreach (DataRow dwTemp in tableLocal.Rows)
                    {
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp["ABPFARBE"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp["ABPFARBE"] = value;
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp["ABPBESCHICH"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp["ABPBESCHICH"] = value; 
                    }
                    set4Return.Merge(setLocal);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex); ;
            }
            return set4Return;
        }
        public DataSet GetABPOSBYLOT(ref ReflectionStudio.Core.Database.INTEXDataSet setData, DataRow dwABPOS)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tableLocal = null;
            //SELECT * FROM WBBST WHERE WBBAUFKRS='FB'AND WBBAUFLFD='000925' AND WBBAUFPOS='010'AND WBBTP='0000'
            string ABPAUFKRS = "", ABPAUFLFD = "", ABPAUFPOS = "", ABPART = "", ABPLIEFNR = "", WBBTP="";
            if (dwABPOS != null)
            {
                ABPAUFKRS = dwABPOS["ABPAUFKRS"].ToString().Trim();
                ABPAUFLFD = dwABPOS["ABPAUFLFD"].ToString().Trim();
                ABPAUFPOS = dwABPOS["ABPAUFPOS"].ToString().Trim();
                ABPART = dwABPOS["ABPART"].ToString().Trim();
                ABPLIEFNR = dwABPOS["LSNAME1"].ToString().Trim();
                WBBTP = dwABPOS["LSNAME1"].ToString().Trim();
            }
            try
            {
                if (OracleDB.State == ConnectionState.Closed)
                {
                    //OracleDB.Open();
                }
                OracleCommand or1 = OracleDB.CreateCommand();
                or1.CommandType = CommandType.StoredProcedure;
                or1.CommandText = "INTEX.HL_GETAB05AV95()";
                //or1.ExecuteNonQuery();
                Connect2Proxy(or1);
                or1 = OracleDB.CreateCommand();
                or1.CommandType = CommandType.Text;
                or1.CommandText = "SELECT * FROM INTEX.ICC_AB05AV95";
                OracleDataAdapter myDa = new OracleDataAdapter(or1);
                //myDa.Fill(setResult);
                setResult=Connect2Proxy(or1);
                #region
                /*
                OracleCommand or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT P.ABPAUFKRS, P.ABPAUFLFD,P.ABPAUFPOS,WBBTP,P.ABPAUFKRS||'.'||P.ABPAUFLFD||'.'||P.ABPAUFPOS||'.'||WBBTP AS ABPLOT"
                + ",trim(P.ABPART)||'-'||trim(P.ABPFARBE)||'-'||P.ABPVAR AS ARTICLE,P.ABPEALFM,ABPWVDAT,"
                     + "P.ABPART,P.ABPVAR,P.ABPFARBE,P.ABPBESCHICH,P.ABPRESMGE,P.ABPSOLLMENGE1,P.ABPRESSTK,P.ABPZUGSTK,P.ABPLIEFDAT,P.ABPERLKZ,P.ABPERLDAT"
                 + ", B.WBBDPART AS SIZEBATCHNO,CAST(MIN(W.WBEWWERTDAT) AS VARCHAR(10)) AS GISSUEDATE, WBBTP,"
                 + " CAST(0+SUM(W.WBEWMTR) AS VARCHAR(20)) AS GMETER,CAST(COUNT(*) AS VARCHAR(20)) AS GPCNUM"
                 + ", '0' AS FMETER "
                 + " FROM ABPOS P LEFT JOIN WBBEW W ON W.WBEWMANDANT = P.ABPMANDANT "
                 + " AND W.WBEWAUFKRS=P.ABPAUFKRS AND W.WBEWAUFLFD=P.ABPAUFLFD AND W.WBEWAUFPOS=P.ABPAUFPOS "
                 + " AND  W.WBEWWAKZ='R' AND W.WBEWBS='21' AND W.WBEWAFOLGE='010' AND W.WBEWFC='AV10' "
                 + "  LEFT JOIN WBBST B ON W.WBEWMANDANT = B.WBBMANDANT AND W.WBEWRWKRS = B.WBBRWKRS  AND W.WBEWRWLFD = B.WBBRWLFD AND W.WBEWPOS = B.WBBPOS "
                 + "  WHERE P.ABPMANDANT='00' AND P.ABPERLKZ=:ABPERLKZ  "
                 + " AND W.WBEWBUCHDAT>=:GISSUEDATE AND W.WBEWBUCHDAT<=:FGETDATE "
                 + " AND  P.ABPAUFKRS=:ABPAUFKRS AND P.ABPAUFLFD=:ABPAUFLFD AND P.ABPAUFPOS=:ABPAUFPOS"
                 + " AND P.ABPLIEFNR LIKE '%" + ABPLIEFNR + "%' "
                 + " AND P.ABPART LIKE '%" + ABPART + "%' AND (P.ABPAUFART= 'VA' OR P.ABPAUFART='VF' OR P.ABPAUFART='AM') "
                 + " AND WBBTP LIKE '%"+WBBTP+"%'"
                 + " GROUP BY P.ABPAUFKRS, P.ABPAUFLFD,P.ABPAUFPOS,P.ABPART,P.ABPVAR,P.ABPFARBE,P.ABPBESCHICH,P.ABPRESMGE,P.ABPSOLLMENGE1,P.ABPRESSTK,P.ABPZUGSTK,P.ABPLIEFDAT, W.WBEWAUFKRS,W.WBEWAUFLFD,W.WBEWAUFPOS,B.WBBDPART"
                 + ",P.ABPERLKZ,P.ABPERLDAT,P.ABPEALFM,P.ABPWVDAT,WBBTP"
                 +" ORDER BY 1,2,3,4";
                or1.Parameters.Add("ABPERLKZ", OracleType.NVarChar).Value = dwABPOS["ABPERLKZ"].ToString();
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                or1.Parameters.Add("GISSUEDATE", OracleType.NVarChar).Value = dwABPOS["GISSUEDATE"].ToString();
                or1.Parameters.Add("FGETDATE", OracleType.NVarChar).Value = dwABPOS["FGETDATE"].ToString();
                 * */
                //setResult = Connect2Proxy(or1);
                #endregion
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0]; 
                    tableLocal.TableName = "ABPOS";
                    setData.Merge(tableLocal);
                    Queue Q100 = new Queue();
                    Q100.Enqueue("ABPSOLLMENGE1");
                    Q100.Enqueue("ABPRESMGE");
                    DivideBy100(tableLocal, Q100);
                    Queue Q1000 = new Queue();
                    Q1000.Enqueue("GMETER");
                    DivideBy1000(tableLocal, Q1000); 
                    byte[] b;
                    string value;
                    int count = 1;
                    foreach (DataRow dwTemp in setData.ABPOS.Rows)
                    { 
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp["ABPBESCHICH"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp["ABPBESCHICH"] = value;
                        //GetABFOLGE(dwTemp);
                        //GetGWBORDER(dwTemp);
                        if (dwTemp["GMETER"].ToString().Trim() == "")
                            dwTemp["GMETER"] = 0;
                        count++;
                        string progress = "查询结束:[" + count.ToString() + "] :" + dwTemp["ABPLOT"].ToString();
                        EventDispatcher.Instance.RaiseStatus(progress, StatusEventType.StartProgress);
                    }
                    set4Return.Merge(setResult);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex); ;
            }
            return set4Return;
        }
        public override DataSet GetVKPOS(DataRow dwABPOS)
        {
            DataSet setLocal1 = base.GetVKPOS(dwABPOS);
            string ABAVKAUFTYP = "";
            string LSNAME1 = "";
            string sTemp = "";
            if (setLocal1.Tables.Contains("ABAUFM"))
            {
                foreach (DataRow dwNEW in setLocal1.Tables["ABAUFM"].Rows)
                {
                    ABAVKAUFTYP = dwNEW["ABAVKAUFTYP"].ToString().Trim();
                    if (ABAVKAUFTYP == "K")
                    {
                        dwABPOS["VKPAUFKRS"] = dwNEW["ABAVKAUFKRS"];
                        dwABPOS["VKPAUFLFD"] = dwNEW["ABAVKAUFLFD"];
                        dwABPOS["VKPAUFPOS"] = dwNEW["ABAVKAUFPOS"];
                        dwABPOS["KDKUNDNA"] = dwNEW["KDKUNDNA"];
                        dwABPOS["ABARESQTY"] = dwNEW["ABARESQTY"];
                        dwABPOS["STDBATCHNO"] = dwNEW["STDBATCHNO"];
                        dwABPOS["VKPWUTERM"] = dwNEW["VKPWUTERM"];
                        Tracer.Verbose(" 留位到客单", dwABPOS["VKPAUFKRS"].ToString() + "." + dwABPOS["VKPAUFLFD"].ToString() + "." + dwABPOS["VKPAUFPOS"].ToString());
                    }
                }
            }
            return setLocal1;
        }
        public DataSet GetGWBORDER(DataRow dwABPOS)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tableLocal = null;
            try
            {
                if (OracleDB.State == ConnectionState.Closed)
                    OracleDB.Open();
                OracleCommand or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT DISTINCT P.ABPAUFKRS as WBAUFKRS,P.ABPLIEFDAT AS GRPENDDATE,P.ABPLIEFDAT AS GRPSTARTDATE"
                + ",P.ABPAUFLFD AS WBAUFLFD,P.ABPAUFPOS AS WBAUFPOS"
                + ", LSNAME1 FROM ABPOS P, ABAUFM M,ABFOLGE F,LIEFDAT L"
                    + " WHERE P.ABPAUFKRS=M.ABAAUFKRS AND P.ABPAUFLFD=M.ABAAUFLFD AND P.ABPAUFPOS=M.ABAAUFPOS"
                + " AND P.ABPAUFKRS=F.ABFAUFKRS AND P.ABPAUFLFD=F.ABFAUFLFD AND P.ABPAUFPOS=F.ABFAUFPOS"
                + " AND  F.ABFLIEFNR=L.LSLIEFNR"
                + " AND  P.ABPAUFART in ('DI','PR')"
                + " AND ABAVKAUFKRS=:ABAVKAUFKRS AND ABAVKAUFLFD=:ABAVKAUFLFD AND ABAVKAUFPOS=:ABAVKAUFPOS";
                or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                //setResult = Connect2Proxy(or1);
                OracleDataAdapter myDa = new OracleDataAdapter(or1);
                myDa.Fill(setResult);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "RESERVEDORDER";
                    byte[] b;
                    string value;
                    string GPRODUCER = "";
                    string SIZEBATCHNO = "";
                    string LSNAME1 = "";
                    foreach (DataRow dwTemp in tableLocal.Rows)
                    {
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp["LSNAME1"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp["LSNAME1"] = value;

                        LSNAME1 = value + ";";
                        if (!GPRODUCER.Contains(LSNAME1))
                        {
                            GPRODUCER += LSNAME1;
                        }
                    }
                    GPRODUCER += "***";
                    GPRODUCER = GPRODUCER.Replace(";***", "");
                    GPRODUCER = GPRODUCER.Replace("***", "");
                    GPRODUCER = GPRODUCER.Replace(";", Environment.NewLine);
                    dwABPOS["GPRODUCER"] = GPRODUCER;

                    Tracer.Verbose(" 织造厂", GPRODUCER);
                }
                set4Return.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex); ;
            }
            return set4Return;
        }
        public DataSet GetSBATCHNO(DataRow dwABPOS)
        {
            DataSet set4Return = new DataSet();
            DataSet setLocal = new DataSet();
            DataTable tableLocal = null;
            try
            {
                OracleCommand or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT DISTINCT P.ABPAUFKRS as SBAUFKRS"
                + ",P.ABPAUFLFD AS SBAUFLFD,P.ABPAUFPOS AS SBAUFPOS"
                + "  FROM ABPOS P, ABAUFM M"
                    + " WHERE P.ABPAUFKRS=M.ABAAUFKRS AND P.ABPAUFLFD=M.ABAAUFLFD AND P.ABPAUFPOS=M.ABAAUFPOS"
                            + " AND  P.ABPAUFART in ('VW')"
                + " AND M.ABAVKAUFKRS=:ABAVKAUFKRS AND M.ABAVKAUFLFD=:ABAVKAUFLFD AND M.ABAVKAUFPOS=:ABAVKAUFPOS";
                or1.Parameters.Add("ABAVKAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                or1.Parameters.Add("ABAVKAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                or1.Parameters.Add("ABAVKAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                setLocal = Connect2Proxy(or1);

                if (setLocal.Tables.Count > 0)
                {
                    tableLocal = setLocal.Tables[0];
                    tableLocal.TableName = "ABFOLGE";

                    byte[] b;
                    string value;
                    foreach (DataRow dwTemp in tableLocal.Rows)
                    {
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp["SBAUFKRS"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp["SBAUFKRS"] = value;
                    }
                }
                set4Return.Merge(setLocal);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex); ;
            }
            return set4Return;
        }
        public DataSet GetGREIGEINFO(DataRow dwABPOS)
        {

            DataSet set4Return = new DataSet();
            //return set4Return;
            DataSet setResult = new DataSet();
            DataTable tableLocal = null;
            try
            {
                if (OracleDB.State == ConnectionState.Closed)
                    OracleDB.Open();
                OracleCommand or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT B.WBBDPART AS SIZEBATCHNO,MIN(W.WBEWWERTDAT) AS GISSUEDATE, 0+SUM(W.WBEWMTR) AS GMETER,COUNT(*) AS GPCNUM "
                + " FROM WBBEW W, WBBST B"
                + " WHERE W.WBEWMANDANT = B.WBBMANDANT AND W.WBEWRWKRS = B.WBBRWKRS "
                + " AND W.WBEWRWLFD = B.WBBRWLFD AND W.WBEWPOS = B.WBBPOS"
                + " AND W.WBEWMANDANT='00'"
                + " AND W.WBEWWAKZ='R' AND W.WBEWBS='21' AND W.WBEWAFOLGE='010' AND W.WBEWFC='AV10' "
                    //  + " AND WBEWSTKNR=WBBSTKNR "
                + " AND W.WBEWAUFKRS=:ABPAUFKRS AND W.WBEWAUFLFD=:ABPAUFLFD AND W.WBEWAUFPOS=:ABPAUFPOS"
                + " GROUP BY W.WBEWAUFKRS,W.WBEWAUFLFD,W.WBEWAUFPOS,B.WBBDPART";
                /* 
                or1.CommandText = "SELECT WBBDPART,MIN(WBBNEUDAT) AS GISSUEDATE,SUM(WBBSSTKLG) AS GMETER,COUNT(*) AS GPCNUM"
                    +" FROM WBBST"
                    +" WHERE WBBAUFKRS=:WBBAUFKRS AND WBBAUFLFD=:WBBAUFLFD AND WBBAUFPOS=:WBBAUFPOS"
                    +" GROUP BY WBBAUFKRS,WBBAUFLFD,WBBAUFPOS,WBBDPART";*/
                or1.Parameters.Add("ABPAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                or1.Parameters.Add("ABPAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                or1.Parameters.Add("ABPAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                //setLocal = Connect2Proxy(or1);
                OracleDataAdapter myDa = new OracleDataAdapter(or1);
                myDa.Fill(setResult);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "WBBEW";
                    Queue Q1000 = new Queue();
                    Q1000.Enqueue("GMETER");
                    DivideBy1000(tableLocal, Q1000);

                    byte[] b;
                    string value;
                    foreach (DataRow dwTemp in tableLocal.Rows)
                    {
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp["SIZEBATCHNO"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp["SIZEBATCHNO"] = value;
                    }
                }

                string GISSUEDATE = "", sGISSUEDATE;
                decimal GMETER = 0, sGMETER;
                decimal GPCNUM = 0, sGPCNUM;
                string sTemp = "";
                string SIZEBATCHNO = "";
                if (setResult.Tables.Contains("WBBEW"))
                {
                    foreach (DataRow dwNEW in setResult.Tables["WBBEW"].Rows)
                    {
                        sTemp = dwNEW["SIZEBATCHNO"].ToString().Trim();
                        sGISSUEDATE = dwNEW["GISSUEDATE"].ToString().Trim();
                        sGMETER = System.Convert.ToDecimal(dwNEW["GMETER"].ToString().Trim());
                        sGPCNUM = System.Convert.ToDecimal(dwNEW["GPCNUM"].ToString().Trim());
                        if (!SIZEBATCHNO.Contains(sTemp))
                        {
                            SIZEBATCHNO += sTemp + ";";
                            GISSUEDATE = sGISSUEDATE;
                            GMETER += sGMETER;
                            GPCNUM += sGPCNUM;
                        }
                    }
                    SIZEBATCHNO += "***";
                    SIZEBATCHNO = SIZEBATCHNO.Replace(";***", "");
                    SIZEBATCHNO = SIZEBATCHNO.Replace("***", "");
                    SIZEBATCHNO = SIZEBATCHNO.Replace(";", Environment.NewLine);
                    dwABPOS["GISSUEDATE"] = GISSUEDATE;
                    dwABPOS["GMETER"] = GMETER;
                    dwABPOS["GPCNUM"] = GPCNUM;
                    dwABPOS["SIZEBATCHNO"] = SIZEBATCHNO;
                }

                Tracer.Verbose(" 送货信息", dwABPOS["GISSUEDATE"].ToString() + ":" + dwABPOS["GMETER"].ToString() + "(" + dwABPOS["GPCNUM"].ToString() + ")");

                set4Return.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex); ;
            }
            return set4Return;
        }
        public DataSet GetFFABRICINFO(DataRow dwABPOS)
        {
            DataSet set4Return = new DataSet();
            DataSet setLocal = new DataSet();
            DataTable tableLocal = null;
            string sTemp = dwABPOS["GMETER"].ToString().Trim();
            if (sTemp == "")
                sTemp = "0";
            decimal GMETER = System.Convert.ToDecimal(sTemp);
            if (GMETER == 0)
                return set4Return;
            try
            {
                OracleCommand or1 = OracleDB.CreateCommand();
                or1.CommandText = "SELECT B.WBEWTP,  MIN(A.WBEWWERTDAT) AS WBEWWERTDAT,SUM(A.WBEWMTR*0.001) AS WBEWMTR,COUNT(A.WBEWSTKNR) AS GPCNUM  FROM WBBEW A JOIN WBBEW B"
                    + " ON A.WBEWBELEG=B.WBEWBELEG"
                    + " WHERE  A.WBEWMANDANT='00' AND A.WBEWAUFKRS=:WBEWAUFKRS AND A.WBEWAUFLFD=:WBEWAUFLFD AND A.WBEWAUFPOS=:WBEWAUFPOS"
                    + " AND A.WBEWBS='13' AND A.WBEWWAKZ='F' AND B.WBEWWAKZ='R'AND B.WBEWLFDNR=2 AND B.WBEWTP=:WBEWTP"
                    + " GROUP BY B.WBEWTP";
                or1.Parameters.Add("WBEWAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                or1.Parameters.Add("WBEWAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                or1.Parameters.Add("WBEWAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                or1.Parameters.Add("WBEWTP", OracleType.NVarChar).Value = dwABPOS["WBBTP"].ToString();
                setLocal = Connect2Proxy(or1); 
                if (setLocal.Tables.Count > 0)
                {
                    tableLocal = setLocal.Tables[0];
                    tableLocal.TableName = "WBBEW"; 
                    foreach (DataRow dwNEW in setLocal.Tables["WBBEW"].Rows)
                    {
                        dwABPOS["FGETDATE"] = dwNEW["WBEWWERTDAT"];
                        dwABPOS["FMETER"] = dwNEW["WBEWMTR"];
                        dwABPOS["FPCNUM"] = dwNEW["GPCNUM"];
                        dwABPOS["FNGRDIFF"] = GetDate(dwABPOS["FGETDATE"].ToString()) .Subtract(GetDate(dwABPOS["ABPLIEFDAT"].ToString())).Days;
                    }
                    Tracer.Verbose("收货信息", dwABPOS["FGETDATE"].ToString() + ":" + dwABPOS["FMETER"].ToString() + "(" + dwABPOS["FPCNUM"].ToString() + ")");

                }
                set4Return.Merge(setLocal);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex); ;
            }
            return set4Return;
        }
        public DataSet GetABFOLGE(DataRow dwABPOS)
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tableLocal = null;
            try
            {
                if(OracleDB.State==ConnectionState.Closed)
                    OracleDB.Open();
                OracleCommand or1 = OracleDB.CreateCommand();
                or1.CommandText = " SELECT DISTINCT LSLIEFNA,LSNAME1 FROM ABFOLGE F,LIEFDAT L "
                + " WHERE ABFMANDANT='00'  AND  ABFAUFKRS=:ABFAUFKRS AND ABFAUFLFD=:ABFAUFLFD AND ABFAUFPOS=:ABFAUFPOS "
                + " AND F.ABFLIEFNR=L.LSLIEFNR";

                or1.Parameters.Add("ABFAUFKRS", OracleType.NVarChar).Value = dwABPOS["ABPAUFKRS"].ToString();
                or1.Parameters.Add("ABFAUFLFD", OracleType.NVarChar).Value = dwABPOS["ABPAUFLFD"].ToString();
                or1.Parameters.Add("ABFAUFPOS", OracleType.NVarChar).Value = dwABPOS["ABPAUFPOS"].ToString();
                //setLocal = Connect2Proxy(or1);
                OracleDataAdapter myDa = new OracleDataAdapter(or1);
                myDa.Fill(setResult);
                if (setResult.Tables.Count > 0)
                {
                    tableLocal = setResult.Tables[0];
                    tableLocal.TableName = "ABFOLGE";

                    byte[] b;
                    string value;
                    string FPRODUCER = "";
                    string LSNAME1 = "";
                    string Column = "";
                    foreach (DataRow dwTemp in tableLocal.Rows)
                    {
                        Column = "LSNAME1";
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dwTemp[Column].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dwTemp[Column] = value;
                        LSNAME1 = value + ";";
                        if (!FPRODUCER.Contains(LSNAME1))
                        {
                            FPRODUCER += LSNAME1;
                        }
                    }
                    FPRODUCER += "***";
                    FPRODUCER = FPRODUCER.Replace(";***", "");
                    FPRODUCER = FPRODUCER.Replace("***", "");
                    FPRODUCER = FPRODUCER.Replace(";", Environment.NewLine);
                    dwABPOS["FPRODUCER"] = FPRODUCER;
                    Tracer.Verbose(" 后整理厂", FPRODUCER);
                }
                set4Return.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex); ;
            }
            return set4Return;
        }
        public override DataSet GetReservedOrder(DataRow dwABPOS, ref ArrayList listDIOrder, ref ArrayList listPROrder, string OrderNum = "")
        {
            DataSet set4Return = new DataSet();
            DataSet setResult = new DataSet();
            DataTable tableLocal = null;
            DataRow dwNABPOS = dwABPOS.Table.Clone().NewRow();
            double WFPENDDATE = System.Convert.ToDouble(dwABPOS["WFPENDDATE"].ToString());
            double GRPENDDATE = System.Convert.ToDouble(dwABPOS["GRPENDDATE"].ToString());
            double GRAENDDATE = System.Convert.ToDouble(dwABPOS["GRAENDDATE"].ToString());
            try
            {
                dwNABPOS["ABPAUFKRS"] = dwABPOS["ABPAUFKRS"].ToString();
                dwNABPOS["ABPAUFLFD"] = dwABPOS["ABPAUFLFD"].ToString();
                dwNABPOS["ABPAUFPOS"] = dwABPOS["ABPAUFPOS"].ToString();
                setResult = base.GetReservedOrder(dwNABPOS, ref listDIOrder, ref listPROrder);
                if (setResult.Tables.Count > 0)
                {
                    byte[] b;
                    string value;
                    string OrderType = "";
                    string sTemp = "";
                    string SIZEBATCHNO = "";
                    string SPRODUCER = "";
                    string AB55Order = "", DIOrder = "", PROrder = "", WPRODUCER = "", sxTemp = "";
                    double ABPEALFM = 0, GRALENG = 0, ABPWVDAT = 0, ABPERLDAT = 0, ABPLIEFDAT = 0;
                    WVFactory wvFactory;
                    string FactroyName = "";
                    foreach (DataRow dwTemp in setResult.Tables["RESERVEDORDER"].Rows)
                    {
                        OrderType = dwTemp["ABPAUFART"].ToString().Trim();
                        AB55Order = dwTemp["ABPAUFKRS"].ToString() + "-" + dwTemp["ABPAUFLFD"].ToString() + "-" + dwTemp["ABPAUFPOS"].ToString();
                        sTemp = dwTemp["EXTPRODUCER"].ToString();
                        if (!WPRODUCER.Contains(sTemp + ";"))
                        {
                            WPRODUCER += sTemp + ";";
                            FactroyName = sTemp;
                        }
                        ABPEALFM = System.Convert.ToDouble(dwTemp["ABPEALFM"]);
                        ABPWVDAT = System.Convert.ToDouble(dwTemp["ABPWVDAT"].ToString());
                        if (WFPENDDATE < ABPWVDAT)
                            WFPENDDATE = ABPWVDAT;
                        ABPLIEFDAT = System.Convert.ToDouble(dwTemp["ABPLIEFDAT"].ToString());
                        if (GRPENDDATE < ABPLIEFDAT)
                            GRPENDDATE = ABPLIEFDAT;
                        ABPERLDAT = System.Convert.ToDouble(dwTemp["ABPERLDAT"].ToString());
                        if (GRAENDDATE < ABPERLDAT)
                            GRAENDDATE = ABPERLDAT;
                        if (OrderType == "DI"
                            && !DIOrder.Contains(AB55Order + ";")
                            )
                        {
                            DIOrder += AB55Order + ";";
                            listDIOrder.Add(AB55Order);
                            wvFactory = new WVFactory(AB55Order, FactroyName);
                            wvFactory.PBFactoryName = FactroyName;
                            wvFactory.VKPAUFNUM = dwABPOS["VKPAUFNUM"].ToString();
                            wvFactory.KDKUNDNA = dwABPOS["KDKUNDNA"].ToString();
                            wvFactory.VKPWUTERM = dwABPOS["VKPWUTERM"].ToString();
                            wvFactory.STDBATCHNO = dwABPOS["STDBATCHNO"].ToString();
                            wvFactory.ARTICLE = dwABPOS["ARTICLE"].ToString();
                            wvFactory.SBEAMLENG = dwABPOS["SBEAMLENG"].ToString();
                            wvFactory.WEFTYARNSTATUS = dwABPOS["WEFTYARNSTATUS"].ToString();
                            wvFactory.SBEAMNO = dwABPOS["SBEAMNO"].ToString();

                            listWVOrder.Add(wvFactory);
                            GRALENG += ABPEALFM;
                            dwABPOS["WBAUFKRS"] = dwTemp["ABPAUFKRS"].ToString();
                            dwABPOS["WBAUFLFD"] = dwTemp["ABPAUFLFD"].ToString();
                            dwABPOS["WBAUFPOS"] = dwTemp["ABPAUFPOS"].ToString();
                        }
                        if (OrderType == "PR")
                        {
                            sTemp = dwTemp["ABADIAUFKRS"].ToString() + "-" + dwTemp["ABADIAUFLFD"].ToString() + "-" + dwTemp["ABADIAUFPOS"].ToString();
                            if (!DIOrder.Contains(sTemp + ";")
                                && sTemp != "  -000000-000"
                                )
                            {
                                DIOrder += sTemp + ";";
                                listDIOrder.Add(sTemp);
                                wvFactory = new WVFactory(sTemp, FactroyName);
                                wvFactory.PBFactoryName = FactroyName;
                                wvFactory.VKPAUFNUM = dwABPOS["VKPAUFNUM"].ToString();
                                wvFactory.KDKUNDNA = dwABPOS["KDKUNDNA"].ToString();
                                wvFactory.VKPWUTERM = dwABPOS["VKPWUTERM"].ToString();
                                wvFactory.STDBATCHNO = dwABPOS["STDBATCHNO"].ToString();
                                wvFactory.ARTICLE = dwABPOS["ARTICLE"].ToString();
                                wvFactory.SBEAMLENG = dwABPOS["SBEAMLENG"].ToString();
                                wvFactory.WEFTYARNSTATUS = dwABPOS["WEFTYARNSTATUS"].ToString();
                                wvFactory.SBEAMNO = dwABPOS["SBEAMNO"].ToString();
                                listWVOrder.Add(wvFactory);
                            }
                            PROrder += AB55Order + ";";
                            listPROrder.Add(AB55Order);
                        }
                    }
                    dwABPOS["GRALENG"] = ABPEALFM;
                    DIOrder += "***";
                    DIOrder = DIOrder.Replace(";***", "");
                    DIOrder = DIOrder.Replace("***", "");
                    dwABPOS["GWBORDER"] = DIOrder;

                    dwABPOS["GPBORDER"] = PROrder;
                    WPRODUCER += "***";
                    WPRODUCER = WPRODUCER.Replace(";***", "");
                    WPRODUCER = WPRODUCER.Replace("***", "");
                    dwABPOS["WPRODUCER"] = WPRODUCER;
                    dwABPOS["WFPENDDATE"] = WFPENDDATE;
                    dwABPOS["GRPENDDATE"] = GRPENDDATE;
                    dwABPOS["GRAENDDATE"] = GRAENDDATE;
                }
                set4Return.Merge(setResult);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex); ;
            }
            return set4Return;
        }
        public override void BuildABPOS(DataRow dwABPOS)
        {


            base.BuildABPOS(dwABPOS);
            DataRow dwNABPOS = dwABPOS.Table.Clone().NewRow();
            dwNABPOS.ItemArray = dwABPOS.ItemArray;
            DataSet set4Return = new DataSet();
            ABPOS = dwNABPOS["ABPAUFKRS"].ToString() + "." + dwNABPOS["ABPAUFLFD"].ToString() + "." + dwNABPOS["ABPAUFPOS"].ToString();
            this.Name = ABPOS;
            Tracer.Verbose(ThreadID.ToString(), "查询开始:[" + ThreadID.ToString() + "] :" + ABPOS);
            try
            {
                #region----------------------- 查询客单----------------------------
                //GetVKPOS(dwNABPOS);
                #endregion

                #region----------------------- 后整理厂----------------------------
                GetABFOLGE(dwNABPOS);
                #endregion

                #region-----------------------织造厂----------------------------

                GetGWBORDER(dwNABPOS);

                #endregion

                #region-----------------------坯布送货信息----------------------------
                //GetGREIGEINFO(dwNABPOS);
                #endregion

                #region-----------------------收货信息----------------------------

                //GetFFABRICINFO(dwNABPOS);

                #endregion
                Tracer.Verbose(ThreadID.ToString(), "查询结束:[" + ThreadID.ToString() + "] :" + ABPOS);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            finally
            {
                try
                {
                    if (dwNABPOS["GMETER"].ToString().Trim() == "")
                        dwNABPOS["GMETER"] = 0;
                    decimal GMETER = System.Convert.ToDecimal(dwNABPOS["GMETER"].ToString());
                    decimal FMETER = System.Convert.ToDecimal(dwNABPOS["FMETER"].ToString());
                    decimal FGWASTAGE = 0;
                    if (FMETER > 0)
                    {
                        FGWASTAGE = Math.Round(100 * GMETER / FMETER, 2);
                    }
                    dwNABPOS["FGWASTAGE"] = FGWASTAGE;
                    dwABPOS.ItemArray = dwNABPOS.ItemArray;

                    string progress = "查询进展:[" + ThreadID.ToString() + "] 完成<-FinishedJobs->/<-TotalJobs->";
                    EventDispatcher.Instance.RaiseStatus(progress, StatusEventType.StartProgress);

                }
                catch (Exception ex)
                {
                    Tracer.Error(ex.StackTrace, ex);
                }
            }
        }
    }
}